<form name="form" ng-init="vm.init();refresh(vm.callback);" ng-submit="vm.debug(form.$valid, vm.method)" novalidate>
  <div class="row x-page-header">
    <div class="col-md-12">
      <div class="x-page-title">RegExp 正则表达式</div>
      <div class="pull-right">
        <button id="copy" class="btn btn-success" type="button" data-clipboard-action="copy"
            ng-disabled="vm.regexp == '' || !vm.regexp">复制</button>
        <button class="btn btn-danger" type="button" ng-click="vm.reset()">重置</button>
      </div>
    </div>
  </div>
  <div class="row x-page-body">
    <div class="col-md-7">
      <fieldset>
        <legend>正则表达式知识点
          <font color="blue">（以下内容摘自<a class="x-link"
              href="https://baike.baidu.com/item/正则表达式/1700215?fr=aladdin" target="_blank">百度百科</a>）
          </font>
        </legend>
        <div class="x-page-scope">
          <uib-tabset active="0" type="tabs">
            <uib-tab index="0" heading="元字符列表">
              <table class="table table-bordered">
                <thead>
                  <tr>
                    <th width="10%">元字符</th>
                    <th width="90%">描述</th>
                  </tr>
                </thead>
                <tbody>
                  <tr ng-repeat="metachar in vm.metachars">
                    <td ng-bind-html="metachar.metachar"></td>
                    <td ng-bind-html="metachar.description"></td>
                  </tr>
                </tbody>
              </table>
            </uib-tab>
            <uib-tab index="1" heading="常用正则表达式">
              <table class="table table-bordered">
                <thead>
                  <tr>
                    <th width="50%">作用域</th>
                    <th width="50%">正则表达式</th>
                  </tr>
                </thead>
                <tbody>
                  <tr ng-repeat="regexp in vm.regexps">
                    <td ng-bind-html="regexp.scope"></td>
                    <td ng-bind-html="regexp.regexp"></td>
                  </tr>
                </tbody>
              </table>
            </uib-tab>
          </uib-tabset>
        </div>
      </fieldset>
    </div>
    <div class="col-md-5">
      <fieldset>
        <legend>正则表达式调试</legend>
        <div class="x-page-scope">
          <div class="form-group">
            <textarea rows="5" name="text" class="form-control" ng-model="vm.text" placeholder="匹配文本内容" autofocus
                required ng-class="{'x-invalid': form.$submitted && form.text.$invalid}"></textarea>
          </div>
          <div class="form-group">
            <div class="input-group">
              <input type="text" name="regexp" class="form-control" ng-model="vm.regexp" placeholder="正则表达式" required
                  ng-class="{'x-invalid': form.$submitted && form.regexp.$invalid}">
              <span class="input-group-addon">
                <label class="checkbox-inline"><input type="checkbox" ng-model="vm.global">全局搜索</label>
                <label class="checkbox-inline"><input type="checkbox" ng-model="vm.caseIgnored">忽略大小写</label>
              </span>
              <span class="input-group-btn">
                <button type="submit" class="btn btn-primary" ng-click="vm.method = 'match'"
                    ng-disabled="form.$invalid">测试匹配</button>
              </span>
            </div>
          </div>
          <div class="form-group">
            <label class="control-label">匹配结果：</label>
            <textarea rows="8" class="form-control" ng-model="vm.match" readonly></textarea>
          </div>
          <div class="form-group">
            <div class="input-group">
              <input type="text" class="form-control" ng-model="vm.swap" placeholder="替换文本">
              <span class="input-group-btn">
                <button type="submit" class="btn btn-primary" ng-click="vm.method = 'replace'"
                    ng-disabled="form.$invalid || vm.swap == ''">替换</button>
              </span>
            </div>
          </div>
          <div class="form-group">
            <label class="control-label">替换结果：</label>
            <textarea rows="5" class="form-control" ng-model="vm.replace" readonly></textarea>
          </div>
        </div>
      </fieldset>
    </div>
  </div>
</form>
